import { Component, OnInit } from '@angular/core';
import { ApesTreeNode } from '@shared/apes/core';
import { TreeNode } from '@shared/apes/tree-display/treenode';
import { ApesNotificationService } from '@shared/apes/notification';
import * as differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import * as distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import * as isSameDay from 'date-fns/is_same_day'
import * as subDays from 'date-fns/sub_days'
@Component({
  selector: 'apes-demo01',
  templateUrl: './demo01.component.html',
  styles: [`
    legend {
      display: block;
      width: 100%;
      padding: 0;
      margin-bottom: 20px;
      font-size: 16px;
      line-height: inherit;
      color: rgba(0, 0, 0, 0.45);
      border: 0;
      border-bottom: 1px solid #d9d9d9;
    }
  `],
})
export class Demo01Component implements OnInit {
  visible = false;
  expandKeys = [ '1001', '10001' ];
  valueTree:string;
  open(): void {
    this.visible = true;
  }
  onChange(param){
    console.log(param);
  }
  close(): void {
    this.visible = false;
  }
  /* date-picker data */
  today = new Date();

  disabledDate = (current: Date): boolean => {
    // Can not select days before today and today
    return differenceInCalendarDays(this.today, current) > 30;
  };
  nodes = [
    new ApesTreeNode({
      title: 'root1',
      key: '1001',
      children: [
        {
          title: 'child1',
          key: '10001',
          children: [
            {
              title: 'child1.1',
              key: '100011',
              children: []
            },
            {
              title: 'child1.2',
              key: '100012',
              children: [
                {
                  title: 'grandchild1.2.1',
                  key: '1000121',
                  isLeaf: true,
                  disabled: true
                },
                {
                  title: 'grandchild1.2.2',
                  key: '1000122',
                  isLeaf: true
                }
              ]
            }
          ]
        }
      ]
    }),
    new ApesTreeNode({
      title: 'root2',
      key: '1002',
      children: [
        {
          title: 'child2.1',
          key: '10021',
          children: [],
          disableCheckbox: true
        },
        {
          title: 'child2.2',
          key: '10022',
          children: [
            {
              title: 'grandchild2.2.1',
              key: '100221',
              isLeaf: true
            }
          ]
        }
      ]
    })
  ];
  /*apes-header data*/
  buttonList = [
    { label: '新增', style: 'highlight', id: 'add' },
    { label: '编辑', style: 'primary', id: 'edit' },
    { label: '修改', style: 'default', id: 'update' },
    { label: '退回', style: 'default', id: 'back' },
    { label: '提交', style: 'disabled', id: 'submit' },
  ];

  statusList = [
    { step: 'one', label: '采购申请', states: 'sent' },
    { step: 'one', label: '采购订单', states: 'purchase' },
    { step: 'one', label: '已完成', states: 'done' },
    { step: 'one', label: '已取消', states: 'cancel' },
  ];

  /*select data*/
  selectValue;

  options = [
    { value: 'jack', label: 'Jack' },
    { value: 'lucy', label: 'Lucy' },
    { value: 'disabled', label: 'Disabled', disabled: true },
  ];

  //日期控件相关定义
  _dateRange = [null, null];
  _startDate;
  _endDate;
  _endTime;
  _disabledStartDate: boolean = false;
  _disabledEndDate: boolean = false;

  cities: any[] = [
    { id: 1, name: 'Vilnius' },
    { id: 2, name: 'Kaunas' },
    { id: 3, name: 'Pabrade' },
  ];

  /*ng-select data*/
  selectedValue2;

  listOfOption = [];
  listOfTagOptions = [];

  addTag(name) {
    return { name: name, tag: true };
  }

  people = [
    { id: 'jack', name: 'Jack' },
    { id: 'lucy', name: 'Lucy' },
    { id: 'tom', name: 'TOM' },
    { id: 'disabled', name: 'Disabled', disabled: true },
  ];

  people1 = [
    { id: 1, name: 'Jack', age: 20, city: 'US', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 2, name: 'Lucy', age: 23, city: 'US', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 3, name: 'TOM', age: 18, city: 'US', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 4, name: 'Mick', age: 38, city: 'UK', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 5, name: 'Roi', age: 24, city: 'UK', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 6, name: 'NI', age: 28, city: 'UK', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 7, name: 'CH', age: 21, city: 'CH', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 8, name: 'Roe', age: 34, city: 'CN', title: 'I\'m a long text, and then you can\'t see me.' },
    { id: 9, name: 'Hi', age: 14, city: 'CN', title: 'I\'m a long text, and then you can\'t see me.' },
  ];

  accounts = [
    { name: 'Adam', email: 'adam@email.com', age: 12, country: 'United States', child: { state: 'Active' } },
    { name: 'Samantha', email: 'samantha@email.com', age: 30, country: 'United States', child: { state: 'Active' } },
    { name: 'Amalie', email: 'amalie@email.com', age: 12, country: 'Argentina', child: { state: 'Active' } },
    { name: 'Estefanía', email: 'estefania@email.com', age: 21, country: 'Argentina', child: { state: 'Active' } },
    { name: 'Adrian', email: 'adrian@email.com', age: 21, country: 'Ecuador', child: { state: 'Active' } },
    { name: 'Wladimir', email: 'wladimir@email.com', age: 30, country: 'Ecuador', child: { state: 'Inactive' } },
    { name: 'Natasha', email: 'natasha@email.com', age: 54, country: 'Ecuador', child: { state: 'Inactive' } },
    { name: 'Nicole', email: 'nicole@email.com', age: 43, country: 'Colombia', child: { state: 'Inactive' } },
    { name: 'Michael', email: 'michael@email.com', age: 15, country: 'Colombia', child: { state: 'Inactive' } },
    { name: 'Nicolás', email: 'nicole@email.com', age: 43, country: 'Colombia', child: { state: 'Inactive' } },
  ];

  /*steps data*/
  steps01 = [{
    current: 2, status: 'error', items: [
      { status: 'finish', title: '洗车不干净', Description: '25分钟' },
      { status: 'process', title: '待门店处理', Description: '25分钟' },
      { status: 'wait', title: '待客服中心处理', Description: '50分钟' },
      { status: 'wait', title: '结单' },
      { status: 'error', title: '停单中' },
    ],
  }];

  steps02 = [{
    current: 2, status: 'error', items: [
      { status: 'finish', title: '洗车不干净', Description: '25分钟', icon: 'anticon anticon-check' },
      { status: 'process', title: '待门店处理', Description: '25分钟', icon: 'anticon anticon-ellipsis' },
      { status: 'wait', title: '待客服中心处理', Description: '50分钟', icon: 'anticon anticon-solution' },
      { status: 'wait', title: '结单', icon: 'anticon anticon-question' },
      { status: 'error', title: '停单中' },
    ],
  }];

  steps03 = [{
    items: [
      { status: 'string', title: '07-07 10:20', type: '报案', Description: '01  天' },
      { status: 'string', title: '07-07 10:20', type: '评估', Description: '23小时' },
      { status: 'stringProcess', title: '07-07 10:20', type: '开始定损', Description: '30分钟' },
      { status: 'stringWait', type: '技术审核' },
      { status: 'stringWait', type: '完成定损' },
      { status: 'stringWait', type: '完成理赔' },
    ],
  }];


  steps04 = [{
    items: [
      {Description: "管理不到位", type: "小病大修悉数退还", status: "stringMore"},
      {Description: 0, title: "转OA", status: "finish", icon: 'anticon anticon-check'},
      {Description: 47426, type: "客服", title: "伍莉莉", status: "stringWait"},
      {title: "停单中", status: "error"}
    ],
  }];

  /*subtotal data*/
  subTotalListLeft = [
    { remarks: 'remarks here', placeholder: 'Please enter remarks here...' },
    // { remarks: '备注项', placeholder: '请在这里输入备注...' }
  ];

  subTotalListRight = [
    { dataName: 'Untaxed Amount', field: 1000.12 },
    { dataName: 'Untaxed Amount', field: 1000.12 },
    { dataName: 'Untaxed Amount', field: 1000.12 },
    { dataName: 'Untaxed Amount', field: 1000.12 },
    { dataName: 'Taxes', field: 500.23 },
  ];

  /*tree data*/
  TreeCommon = [{
    'id': 1,
    'label': '查询',
    'data': '树形查询 Uuohzh Uxhmbpx Nrtlosm Ihvjvc Zpb Nhbqd',
    'expandedIcon': 'anticon-folder-open',
    'collapsedIcon': 'anticon-folder',
    'children': [
      {
        'id': 10001,
        'label': '合同管理',
        'data': '合同管理 Pfunio Atkhv Ryxmm Xyidjxpqti Fmedcvdso',
        'expandedIcon': 'anticon-folder-open',
        'collapsedIcon': 'anticon-folder',
        'children': [
          {
            'id': 20001,
            'label': '采购合同管理',
            'data': '采购合同管理 Nst Bfyrlqjhbf Qqnfoqe Udvusxl Lwqs',
            'expandedIcon': 'anticon-folder-open',
            'collapsedIcon': 'anticon-folder',
            'children': [
              {
                'id': 30001,
                'label': '制定采购合同',
                'data': '制定采购合同 Tvlgdqrg Tdogvkhysl Tphscs Tqktovcdod',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40001,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Ilqkcztdr Nxxnvfbsa Yishhsnti',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'expanded': true,
                    'children': [
                      {
                        'id': 50001,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50002,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50003,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40002,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Ecng Omabjkgfc Lvnp Bdpfyp Hzs Fbm Wpjidipsy',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50004,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50005,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50006,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40003,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Mwkpxexhm Sdcehgip Njmlshvd Jlfrlpe Sbjyc',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50007,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50008,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50009,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
              {
                'id': 30002,
                'label': '制定采购合同',
                'data': '制定采购合同 Cxfciqkno Yki Sqmtdg',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40004,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Mcna Fesctf Qrtdxqpsn Rwmhgjxdy',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50010,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50011,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50012,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40005,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Pxzcf Ukemmqewm Osqqqnw Usxi Ppixe',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50013,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50014,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50015,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
            ],
          },
        ],
      },
      {
        'id': 10002,
        'label': '合同管理',
        'data': '合同管理 Nscfoutt Ouqdsbivs Lcek Hjzh Jnktjdyav',
        'expandedIcon': 'anticon-folder-open',
        'collapsedIcon': 'anticon-folder',
        'children': [
          {
            'id': 20002,
            'label': '采购合同管理',
            'data': '采购合同管理 Otytaur Vfmkhl Hnqretq Kjkeei Wyfjqwz Yijfrafb',
            'expandedIcon': 'anticon-folder-open',
            'collapsedIcon': 'anticon-folder',
            'children': [
              {
                'id': 30003,
                'label': '制定采购合同',
                'data': '制定采购合同 Odt Lyxmwdhoy Asbcnyapc Naedpcvi',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40006,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Poputt Pvqi Jnfxdhi Pbvjtk Cgf Wfvkjslgmb',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50016,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50017,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50018,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
              {
                'id': 30004,
                'label': '制定采购合同',
                'data': '制定采购合同 Hqruy Jufiydv Feto Thlfrbofg Krkbv',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40007,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Dtwp Jobmb Rrxplqn Vrsfeuim Labceku Iqdaqf Udkckyqzft',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50019,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50020,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50021,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
              {
                'id': 30005,
                'label': '制定采购合同',
                'data': '制定采购合同 Royvuk Jysttu Fhjwxec Fwhoogwumi',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40008,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Edizmd Whqumy Wduhqkcdv Rnesp',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50022,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50023,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50024,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40009,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Lnvehe Qylnlokcq Ahkknc Bagjzqxbsq Ohfq Fpgec',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50025,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50026,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50027,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
            ],
          },
        ],
      },
      {
        'id': 10003,
        'label': '合同管理',
        'data': '合同管理 Embrh Haxpobbkmn Drkvu Twqiwvp',
        'expandedIcon': 'anticon-folder-open',
        'collapsedIcon': 'anticon-folder',
        'children': [
          {
            'id': 20003,
            'label': '采购合同管理',
            'data': '采购合同管理 Suvioh Dxeylgbb Tkusi Epfdmjafzp Yydfcjv',
            'expandedIcon': 'anticon-folder-open',
            'collapsedIcon': 'anticon-folder',
            'children': [
              {
                'id': 30006,
                'label': '制定采购合同',
                'data': '制定采购合同 Msfhtvceo Xgnjst Vucvteqq Beoemvihkw Mpdi Jcjpgdxt',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40010,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Xgcgteprpe Ipthfrxb Rigpato Ftlnmxjw Gyecdi Qxlaoy Lwupxcgqe',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50028,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50029,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50030,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40011,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Bceodkrwv Job Hmmlka Rspguvgtw Gqu',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50031,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50032,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50033,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40012,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Jenvfhaiqj Pchjwwll Lzhxkzvj Ksssdica Ilufct',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50034,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50035,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50036,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
            ],
          },
          {
            'id': 20004,
            'label': '采购合同管理',
            'data': '采购合同管理 Bhkoivgp Ieqls Mmrlxqccz',
            'expandedIcon': 'anticon-folder-open',
            'collapsedIcon': 'anticon-folder',
            'children': [
              {
                'id': 30007,
                'label': '制定采购合同',
                'data': '制定采购合同 Crfecmimcp Pzmr Gpakfe Crcod Cbqydffrly Ldqkzbwqi Quos',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40013,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Hxapje Iggwg Ybjqwissn Ivq Tcrx Uwcqire',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50037,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50038,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50039,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40014,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Xbemnqlnm Hhdw Fslisjjh Upqavvxjp',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50040,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50041,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50042,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
              {
                'id': 30008,
                'label': '制定采购合同',
                'data': '制定采购合同 Dwrgjjd Nbpxdtnmu Ekuxebgr Vdhhnfl Mfus Bjhwf',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40015,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Asgy Rkgk Jyioenq',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50043,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50044,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50045,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                  {
                    'id': 40016,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Hmihxly Nydrxgq Vwvdndkyn Iibiul Wlulxoz Eecflh',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50046,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50047,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50048,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
              {
                'id': 30009,
                'label': '制定采购合同',
                'data': '制定采购合同 Dvjy Gjvpmp Xpqtwxgkab Ykoujikvg Ybnm Qdmshbl',
                'expandedIcon': 'anticon-folder-open',
                'collapsedIcon': 'anticon-folder',
                'children': [
                  {
                    'id': 40017,
                    'label': '制定采购协议',
                    'data': '制定采购协议 Por Mujsvqrq Fmfsrzmlf Pvlkj Rbqk',
                    'expandedIcon': 'anticon-folder-open',
                    'collapsedIcon': 'anticon-folder',
                    'children': [
                      {
                        'id': 50049,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50050,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                      {
                        'id': 50051,
                        'label': 'Expenses.doc',
                        'icon': 'anticon-file-text',
                        'data': 'Expenses Document',
                      },
                    ],
                  },
                ],
              },
            ],
          },
        ],
      },
    ],
  }];

  Treeloading: boolean;

  selectedFile: TreeNode;
  selectedFile1: TreeNode;
  selectedFiles: TreeNode[];
  selectedFiles1: TreeNode[];

  TreeDemo01: TreeNode[];
  TreeDemo02: TreeNode[];
  TreeDemo03: TreeNode[];
  TreeDemo04: TreeNode[];
  TreeDemo05: TreeNode[];
  TreeDemo06: TreeNode[];
  TreeDemo07: TreeNode[];
  TreeDemo08: TreeNode[];
  TreeDemo09: TreeNode[];


  /* timeline data */
  timedata = [
    {
      data: 'Create a services site',
      color: 'blue',
      businessDate: '2018-08-02 15:01:00',
      operate: ' 部门处理：完成',
      operator: { name: '测试操作员' },
      oaFlag: true,
      remark: '拒绝',
    },
    {
      data: 'Solve initial network problems',
      color: 'red',
      businessDate: '2018-08-01 11:53:00',
      operate: ' 申请停单：拒绝',
      operator: { name: '测试操作员' },
      oaFlag: true,
    },
    {
      data: 'Technical testing',
      color: 'blue',
      businessDate: '2018-07-31 11:53:00',
      operate: ' 保存客诉单',
      operator: { name: '测试操作员' },
      oaFlag: false
    },
    {
      data: 'Network problems being solved',
      color: 'green',
      businessDate: '2018-07-30 11:53:00',
      operate: ' 部门处理：申请停单',
      operator: { name: '测试操作员' },
      oaFlag: true
    },
  ];


  constructor(private notification: ApesNotificationService) {
  }

  ngOnInit(): void {

    /*ng-select data*/
    const children = [];

    for (let i = 10; i < 36; i++) {
      children.push({ label: i.toString(36) + i, value: i.toString(36) + i });
    }
    this.listOfOption = children;


    /*tree data*/
    this.TreeDemo01 = JSON.parse(JSON.stringify(this.TreeCommon));
    setTimeout(() => {
      this.TreeDemo02 = JSON.parse(JSON.stringify(this.TreeCommon));
      this.Treeloading = false;
    }, 5000);
    this.TreeDemo03 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo04 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo05 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo06 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo07 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo08 = JSON.parse(JSON.stringify(this.TreeCommon));
    this.TreeDemo09 = JSON.parse(JSON.stringify(this.TreeCommon));


  }

  /*日期控件*/
  _startValueChange = () => {
    if (this._startDate > this._endDate) {
      this._endDate = null;
    }
  };

  _endValueChange = () => {
    if (this._startDate > this._endDate) {
      this._startDate = null;
    }
  };

  /*tree events*/
  TreenodeSelect(event) {
    console.log('选中时调用');
    console.log(event);
  }
  getAll(param){
    console.log(param);
  }
  TreenodeUnselect(event) {
    console.log('未选中时调用');
    console.log(event);
  }

  clearAllSelect() {
    this.selectedFiles1 = [];
    this.TreeDemo07.forEach(node => {
      this.clearAll(node, false);
    });
  }

  allSelect() {
    this.selectedFiles1 = this.TreeDemo07;
  }

  private clearAll(node: TreeNode, isSelected: boolean) {
    node.partialSelected = isSelected;
    if (node.children) {
      node.children.forEach(childNode => {
        this.clearAll(childNode, isSelected);
      });
    }
  }

  expandAll() {
    this.TreeDemo08.forEach(node => {
      this.expandRecursive(node, true);
    });
  }

  collapseAll() {
    this.TreeDemo08.forEach(node => {
      this.expandRecursive(node, false);
    });
  }

  private expandRecursive(node: TreeNode, isExpand: boolean) {
    node.expanded = isExpand;
    if (node.children) {
      node.children.forEach(childNode => {
        this.expandRecursive(childNode, isExpand);
      });
    }
  }

  onClick() {
    console.log('onClick');
  }

  /* notification data */
  basicNotification(): void {
    this.notification.blank('通知标题', '这是一个通知内容，可以通过事件触发。', { apesDuration: 0 });
  }

  createNotification(type: string): void {
    this.notification.create(type, '通知标题',
      '这是一个通知内容，可以通过事件触发。');
  }

  /* timeline data */
  getDateTime(datetime){
    let date;
    let days;
    let nowDate ;
    date = datetime.substring(10);
    nowDate = distanceInWordsToNow(datetime, {
      locale: (window as any).__locale__,
    });
    if(isSameDay(new Date(), datetime)){
      days = "今天 ";
      return days + nowDate + "前";
    }else if(isSameDay(datetime, subDays(new Date(), 1))){
      days = "昨天" + date;
      return days;
    }else if(isSameDay(datetime, subDays(new Date(), 2))){
      days = "前天" + date;
      return days;
    }else{
      return datetime;
    }
  }
}
